<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>大规模文件存储优化 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            position: relative;
        }
        .code-copy {
            position: absolute;
            top: 8px;
            right: 8px;
            color: #9ca3af;
            cursor: pointer;
            transition: all 0.2s;
        }
        .code-copy:hover {
            color: #fff;
        }
        .table-striped tbody tr:nth-child(odd) {
            background-color: rgba(249, 250, 251, 0.8);
        }
        .table-striped tbody tr:hover {
            background-color: rgba(243, 244, 246, 0.8);
        }
        .tooltip:hover .tooltip-text {
            opacity: 1;
            visibility: visible;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-24 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col items-center text-center">
                <span class="bg-white bg-opacity-20 rounded-full px-4 py-1 text-sm font-medium mb-4">架构设计</span>
                <h1 class="serif text-4xl md:text-5xl font-bold mb-6 leading-tight">大规模文件存储优化</h1>
                <p class="text-xl max-w-3xl opacity-90 mb-8">在现代互联网应用中，海量文件存储已成为不可避免的挑战。无论是电商平台的商品图片、短视频应用的媒体文件，还是企业级数据归档、日志存储，如何高效管理、存储、读取这些数据，是架构设计中必须解决的问题。</p>
                <div class="flex space-x-3">
                    <a href="#challenges" class="px-6 py-3 bg-white text-indigo-600 font-medium rounded-lg hover:bg-opacity-90 transition">了解挑战</a>
                    <a href="#solutions" class="px-6 py-3 border border-white text-white font-medium rounded-lg hover:bg-white hover:bg-opacity-10 transition">解决方案</a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 py-16">
        <!-- Challenges Section -->
        <section id="challenges" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-indigo-500 w-12 mr-4"></div>
                <h2 class="serif text-3xl font-bold">理解大规模文件存储的挑战</h2>
            </div>
            <p class="text-gray-600 mb-8">在优化大规模文件存储之前，我们需要先明确其主要挑战：</p>
            
            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-indigo-100 w-10 h-10 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-database text-indigo-600"></i>
                        </div>
                        <h3 class="font-bold text-lg">海量数据管理</h3>
                    </div>
                    <p class="text-gray-600">TB 级甚至 PB 级的数据存储需要合理的分片、分层策略，避免单点存储瓶颈。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 w-10 h-10 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-users text-blue-600"></i>
                        </div>
                        <h3 class="font-bold text-lg">高并发访问</h3>
                    </div>
                    <p class="text-gray-600">随着用户规模增长，系统需要支撑<strong class="font-semibold">高吞吐量</strong>的文件上传、下载请求。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 w-10 h-10 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-coins text-green-600"></i>
                        </div>
                        <h3 class="font-bold text-lg">存储成本优化</h3>
                    </div>
                    <p class="text-gray-600">大规模数据存储会带来巨大的存储成本，如何在可用性和成本之间取得平衡是一个关键问题。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-red-100 w-10 h-10 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-shield-alt text-red-600"></i>
                        </div>
                        <h3 class="font-bold text-lg">数据安全与合规</h3>
                    </div>
                    <p class="text-gray-600">文件存储涉及用户隐私、业务数据等敏感信息，需要采取有效的访问控制、加密机制。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 w-10 h-10 rounded-lg flex items-center justify-center mr-4">
                            <i class="fas fa-check-circle text-purple-600"></i>
                        </div>
                        <h3 class="font-bold text-lg">数据可靠性</h3>
                    </div>
                    <p class="text-gray-600">数据需要高可用性，防止存储设备故障导致文件丢失。</p>
                </div>
            </div>
        </section>

        <!-- Architecture Optimization -->
        <section id="solutions" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-indigo-500 w-12 mr-4"></div>
                <h2 class="serif text-3xl font-bold">存储架构优化</h2>
            </div>

            <!-- Storage Systems -->
            <div class="mb-12">
                <h3 class="font-bold text-xl mb-4 flex items-center">
                    <span class="bg-indigo-500 w-4 h-4 rounded-full mr-2"></span>
                    选择合适的存储系统
                </h3>
                <p class="text-gray-600 mb-6">根据业务需求，选择合适的存储方式：</p>
                
                <div class="grid md:grid-cols-3 gap-6 mb-6">
                    <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                        <div class="flex items-center mb-3">
                            <div class="bg-indigo-100 w-8 h-8 rounded-lg flex items-center justify-center mr-3">
                                <i class="fas fa-cube text-indigo-600"></i>
                            </div>
                            <h4 class="font-bold text-lg">对象存储</h4>
                        </div>
                        <p class="text-gray-600 text-sm">适用于非结构化数据存储，提供高可扩展性，例如阿里云 OSS、Amazon S3。</p>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                        <div class="flex items-center mb-3">
                            <div class="bg-blue-100 w-8 h-8 rounded-lg flex items-center justify-center mr-3">
                                <i class="fas fa-folder-tree text-blue-600"></i>
                            </div>
                            <h4 class="font-bold text-lg">分布式文件存储</h4>
                        </div>
                        <p class="text-gray-600 text-sm">适用于大数据计算和机器学习场景，例如 HDFS、Ceph。</p>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-sm card-hover">
                        <div class="flex items-center mb-3">
                            <div class="bg-green-100 w-8 h-8 rounded-lg flex items-center justify-center mr-3">
                                <i class="fas fa-cubes text-green-600"></i>
                            </div>
                            <h4 class="font-bold text-lg">块存储</h4>
                        </div>
                        <p class="text-gray-600 text-sm">适用于数据库、高性能计算等低延迟需求的场景，例如 Amazon EBS、阿里云 ESSD。</p>
                    </div>
                </div>
            </div>

            <!-- Sharding Strategy -->
            <div class="mb-12">
                <h3 class="font-bold text-xl mb-4 flex items-center">
                    <span class="bg-indigo-500 w-4 h-4 rounded-full mr-2"></span>
                    分片存储策略
                </h3>
                <p class="text-gray-600 mb-4">对于超大文件（>1GB），可使用<strong class="font-semibold">分片存储</strong>提升性能：</p>
                
                <div class="grid md:grid-cols-2 gap-6 mb-6">
                    <div class="bg-white p-6 rounded-xl shadow-sm">
                        <h4 class="font-bold mb-2 flex items-center">
                            <i class="fas fa-upload text-indigo-500 mr-2"></i>
                            分片上传（Multipart Upload）
                        </h4>
                        <p class="text-gray-600 text-sm">将文件拆分为多个小块并并行上传，提高上传速度。</p>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-sm">
                        <h4 class="font-bold mb-2 flex items-center">
                            <i class="fas fa-network-wired text-blue-500 mr-2"></i>
                            分片存储（Sharding Storage）
                        </h4>
                        <p class="text-gray-600 text-sm">为不同的文件设置唯一标识，并存储到不同的存储节点上，提升负载均衡能力。</p>
                    </div>
                </div>
                
                <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4 rounded-r mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0 text-indigo-500">
                            <i class="fas fa-lightbulb"></i>
                        </div>
                        <div class="ml-3">
                            <h4 class="font-bold text-indigo-800">优化建议</h4>
                            <p class="text-indigo-600">OSS、S3 等对象存储服务均支持 Multipart Upload，可以使用 SDK 实现高效上传。</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Data Tiering -->
            <div class="mb-12">
                <h3 class="font-bold text-xl mb-4 flex items-center">
                    <span class="bg-indigo-500 w-4 h-4 rounded-full mr-2"></span>
                    数据冷热分层存储
                </h3>
                <p class="text-gray-600 mb-6">不同类型的数据访问频率不同，我们可以将数据分为 <strong class="font-semibold">热数据、温数据、冷数据</strong>，采用不同的存储策略：</p>
                
                <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                    <div class="overflow-x-auto">
                        <table class="min-w-full table-striped">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">数据类型</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">访问频率</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">存储方式</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">典型场景</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap font-medium">热数据</td>
                                    <td class="px-6 py-4 whitespace-nowrap">频繁访问</td>
                                    <td class="px-6 py-4 whitespace-nowrap">高性能存储（SSD）</td>
                                    <td class="px-6 py-4 whitespace-nowrap">用户头像、最近上传的文件</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap font-medium">温数据</td>
                                    <td class="px-6 py-4 whitespace-nowrap">偶尔访问</td>
                                    <td class="px-6 py-4 whitespace-nowrap">标准存储（HDD）</td>
                                    <td class="px-6 py-4 whitespace-nowrap">业务系统的历史订单文件</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap font-medium">冷数据</td>
                                    <td class="px-6 py-4 whitespace-nowrap">长期存档</td>
                                    <td class="px-6 py-4 whitespace-nowrap">归档存储（OSS 归档、S3 Glacier）</td>
                                    <td class="px-6 py-4 whitespace-nowrap">备份数据、审计日志</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>

        <!-- Performance Optimization -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-indigo-500 w-12 mr-4"></div>
                <h2 class="serif text-3xl font-bold">性能优化策略</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-blue-500 w-4 h-4 rounded-full mr-2"></span>
                        并行上传与下载
                    </h3>
                    <ul class="space-y-3 mb-6">
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">多线程上传</strong>：使用多线程上传文件，提高文件上传吞吐量。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-blue-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">CDN 结合 OSS 加速下载</strong>：CDN 可缓存热点文件，减少 OSS 直接访问压力。</span>
                        </li>
                    </ul>
                    
                    <div class="mb-6">
                        <h4 class="font-bold text-gray-700 mb-2 flex items-center">
                            <i class="fas fa-code text-blue-500 mr-2"></i>
                            ts：使用 Java SDK 进行多线程分片上传
                        </h4>
                        <div class="code-block relative">
                            <pre class="text-gray-200 p-4 overflow-x-auto"><code>OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
String bucketName = "my-bucket";
String objectName = "large-file.zip";
String filePath = "D:/large-file.zip";

UploadFileRequest uploadFileRequest = new UploadFileRequest(bucketName, objectName);
uploadFileRequest.setUploadFile(filePath);
uploadFileRequest.setTaskNum(5);  // 使用 5 个线程并行上传
uploadFileRequest.setEnableCheckpoint(true);

ossClient.uploadFile(uploadFileRequest);
ossClient.shutdown();</code></pre>
                            <div class="code-copy">
                                <i class="far fa-copy"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-blue-500 w-4 h-4 rounded-full mr-2"></span>
                        预签名 URL 提升访问性能
                    </h3>
                    <p class="text-gray-600 mb-4">对于私有文件，可以使用<strong class="font-semibold">预签名 URL（Pre-signed URL）</strong>，减少权限校验带来的额外开销。</p>
                    
                    <div class="code-block relative">
                        <pre class="text-gray-200 p-4 overflow-x-auto"><code>Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000); // 1 小时有效期
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectName);
request.setExpiration(expiration);
URL url = ossClient.generatePresignedUrl(request);
System.out.println("文件下载链接: " + url.toString());</code></pre>
                        <div class="code-copy">
                            <i class="far fa-copy"></i>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Cost Optimization -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-indigo-500 w-12 mr-4"></div>
                <h2 class="serif text-3xl font-bold">存储成本优化</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-green-500 w-4 h-4 rounded-full mr-2"></span>
                        使用存储生命周期策略
                    </h3>
                    <p class="text-gray-600 mb-4">可配置自动转换存储类型，例如：</p>
                    <ul class="space-y-2 mb-6">
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-green-500 mr-2 mt-1">
                                <i class="fas fa-arrow-right"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">30 天后将文件转为低频存储</strong></span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-green-500 mr-2 mt-1">
                                <i class="fas fa-arrow-right"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">90 天后归档存储</strong></span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-green-500 mr-2 mt-1">
                                <i class="fas fa-arrow-right"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">180 天后自动删除</strong></span>
                        </li>
                    </ul>
                    
                    <p class="text-gray-600 mb-2">示例（阿里云 OSS 配置存储策略）：</p>
                    <div class="code-block relative">
                        <pre class="text-gray-200 p-4 overflow-x-auto"><code>&lt;LifecycleConfiguration&gt;
    &lt;Rule&gt;
        &lt;ID&gt;ArchiveRule&lt;/ID&gt;
        &lt;Prefix&gt;logs/&lt;/Prefix&gt;
        &lt;Status&gt;Enabled&lt;/Status&gt;
        &lt;Transition&gt;
            &lt;Days&gt;30&lt;/Days&gt;
            &lt;StorageClass&gt;IA&lt;/StorageClass&gt;
        &lt;/Transition&gt;
        &lt;Transition&gt;
            &lt;Days&gt;90&lt;/Days&gt;
            &lt;StorageClass&gt;Archive&lt;/StorageClass&gt;
        &lt;/Transition&gt;
        &lt;Expiration&gt;
            &lt;Days&gt;180&lt;/Days&gt;
        &lt;/Expiration&gt;
    &lt;/Rule&gt;
&lt;/LifecycleConfiguration&gt;</code></pre>
                        <div class="code-copy">
                            <i class="far fa-copy"></i>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-green-500 w-4 h-4 rounded-full mr-2"></span>
                        小文件合并存储
                    </h3>
                    <p class="text-gray-600 mb-4">存储大量小文件会占用大量存储请求（API 调用成本高）。可以采用 <strong class="font-semibold">合并存储</strong> 方法：</p>
                    
                    <div class="space-y-4">
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold mb-2 flex items-center">
                                <i class="fas fa-file-archive text-green-500 mr-2"></i>
                                压缩存储
                            </h4>
                            <p class="text-gray-600 text-sm">多个小文件合并为一个压缩包（ZIP、TAR）。</p>
                        </div>
                        
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-bold mb-2 flex items-center">
                                <i class="fas fa-database text-green-500 mr-2"></i>
                                索引存储
                            </h4>
                            <p class="text-gray-600 text-sm">使用数据库记录文件索引，并存储到大文件中，提高读取效率。</p>
                        </div>
                    </div>
                    
                    <div class="mt-6">
                        <div class="mermaid">
                            graph TD
                                A[小文件1] --> C(合并存储)
                                B[小文件2] --> C
                                D[小文件3] --> C
                                C --> E[压缩文件]
                                C --> F[数据库索引]
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Security & Reliability -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="h-1 bg-indigo-500 w-12 mr-4"></div>
                <h2 class="serif text-3xl font-bold">数据安全与可靠性</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-red-500 w-4 h-4 rounded-full mr-2"></span>
                        访问权限控制
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">基于 IAM 角色</strong>，对不同用户设置不同权限。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">Bucket 策略</strong>，设置公共/私有权限。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">加密存储</strong>，确保数据传输安全（AES-256、KMS）。</span>
                        </li>
                    </ul>
                </div>
                
                <div>
                    <h3 class="font-bold text-xl mb-4 flex items-center">
                        <span class="bg-red-500 w-4 h-4 rounded-full mr-2"></span>
                        数据冗余备份
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">多 AZ（可用区）存储</strong>：确保数据可用性。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">跨区域复制（Cross-Region Replication）</strong>：提高数据容灾能力。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="flex-shrink-0 h-5 w-5 text-red-500 mr-2 mt-1">
                                <i class="fas fa-check-circle"></i>
                            </span>
                            <span class="text-gray-600"><strong class="font-semibold">快照（Snapshot）与版本控制</strong>：防止误删除。</span>
                        </li>
                    </ul>
                </div>
            </div>
            
            <div class="mt-8">
                <div class="mermaid">
                    graph LR
                        A[主存储区] -->|同步| B[备用存储区]
                        A -->|跨区域复制| C[异地存储区]
                        D[快照] --> A
                        D --> B
                        D --> C
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-10">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400 mt-1">探索技术无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-150">http://www.yuque.com/jtostring</a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400 text-sm">
                &copy; 2023 技术小馆 版权所有
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            fontFamily: "'Noto Sans SC', sans-serif"
        });

        // Copy code functionality
        document.querySelectorAll('.code-copy').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.parentElement.querySelector('code');
                const text = codeBlock.textContent;
                navigator.clipboard.writeText(text).then(() => {
                    const icon = button.querySelector('i');
                    icon.classList.remove('fa-copy');
                    icon.classList.add('fa-check');
                    setTimeout(() => {
                        icon.classList.remove('fa-check');
                        icon.classList.add('fa-copy');
                    }, 2000);
                });
            });
        });
    </script>
</body>
</html>